home *** CD-ROM | disk | FTP | other *** search
/ ...taking it to the Macs! / ...taking it to the Macs!.iso / Extras / ActiveX Mac SDK / ActiveX SDK / Container Common / npapi.h < prev    next >
Text File  |  1997-01-03  |  7KB  |  262 lines

  1. /*
  2.  *  npapi.h $Revision: 2 $
  3.  *  Netscape client plug-in API spec
  4.  */
  5.  
  6. #ifndef _NPAPI_H_
  7. #define _NPAPI_H_
  8.  
  9. #ifdef __MWERKS__
  10. #pragma options align=mac68k
  11. #endif
  12.  
  13. /* XXX this needs to get out of here */
  14. #if defined(__MWERKS__)
  15. #ifndef XP_MAC
  16. #define XP_MAC
  17. #endif
  18. #endif
  19.  
  20.  
  21. /*
  22.  *  Version constants
  23.  */
  24.  
  25. #define NP_VERSION_MAJOR 0
  26. #define NP_VERSION_MINOR 6
  27.  
  28.  
  29.  
  30. /* 
  31.  *  Basic types
  32.  */
  33.  
  34. #ifndef _UINT16
  35. typedef unsigned short uint16;
  36. #endif
  37. #ifndef _UINT32
  38. typedef unsigned long uint32;
  39. #endif
  40. #ifndef _INT16
  41. typedef short int16;
  42. #endif
  43. #ifndef _INT32
  44. typedef long int32;
  45. #endif
  46.  
  47. #ifndef FALSE
  48. #define FALSE (0)
  49. #endif
  50. #ifndef TRUE
  51. #define TRUE (1)
  52. #endif
  53. #ifndef NULL
  54. #define NULL (0L)
  55. #endif
  56.  
  57. typedef unsigned char   NPBool;
  58. typedef void*           NPEvent;
  59. typedef int16           NPError;
  60. typedef char*           NPMIMEType;
  61.  
  62.  
  63. /*
  64.  *  NPP is a plug-in's opaque instance handle
  65.  */
  66. typedef struct _NPP
  67. {
  68.     void*   pdata;                /* plug-in private data */
  69.     void*   ndata;                /* netscape private data */
  70. } NPP_t;
  71.  
  72. typedef NPP_t*  NPP;
  73.  
  74.  
  75.  
  76. typedef struct _NPStream
  77. {
  78.     void*       pdata;                /* plug-in private data */
  79.     void*       ndata;                /* netscape private data */
  80.     const char* url;
  81.     uint32      end;
  82.     uint32      lastmodified;
  83. } NPStream;
  84.  
  85. typedef struct _NPByteRange
  86. {
  87.     int32                   offset;                /* negative offset means from the end */
  88.     uint32                  length;
  89.     struct _NPByteRange*    next;
  90. } NPByteRange;
  91.  
  92.  
  93. typedef struct _NPSavedData
  94. {
  95.     int32   len;
  96.     void*   buf;
  97. } NPSavedData;
  98.  
  99.  
  100.  
  101. typedef struct _NPRect
  102. {
  103.     uint16  top;
  104.     uint16  left;
  105.     uint16  bottom;
  106.     uint16  right;
  107. } NPRect;
  108.  
  109. typedef struct _NPWindow 
  110. {
  111.     void*   window;                 /* platform specific window handle */
  112.     uint32  x;                      /* position of top left corner relative to a netscape page */
  113.     uint32  y;                   
  114.     uint32  width;                  /* maximum window size */
  115.     uint32  height;
  116.     NPRect  clipRect;               /* clipping rectangle in port coordinates */
  117. } NPWindow;
  118.  
  119.  
  120.  
  121. typedef struct _NPFullPrint
  122. {
  123.     NPBool      pluginPrinted;      /* Set TRUE if plugin handled fullscreen printing */
  124.     NPBool      printOne;           /* TRUE if plugin should print one copy to default printer */
  125.     void*       platformPrint;      /* Platform-specific printing info */
  126. } NPFullPrint;
  127.  
  128. typedef struct _NPEmbedPrint
  129. {
  130.     NPWindow    window;
  131.     void*       platformPrint;      /* Platform-specific printing info */
  132. } NPEmbedPrint;
  133.  
  134. typedef struct _NPPrint
  135. {
  136.     uint16              mode;       /* NP_FULL or NP_EMBED */
  137.     union
  138.     {
  139.         NPFullPrint     fullPrint;  /* if mode is NP_FULL */
  140.         NPEmbedPrint    embedPrint; /* if mode is NP_EMBED */
  141.     } print;
  142. } NPPrint;
  143.  
  144.  
  145.  
  146.  
  147. #ifdef XP_MAC
  148.  
  149. /*
  150.  *  Mac-specific structures and definitions.
  151.  */
  152.  
  153. typedef struct NP_Port
  154. {
  155.     CGrafPtr    port;           /* Grafport */
  156.     int32       portx;          /* position inside the topmost window */
  157.     int32       porty;
  158. } NP_Port;
  159.  
  160. /*
  161.  *  Non-standard event types that can be passed to HandleEvent
  162.  */
  163. #define getFocusEvent       (osEvt + 16)
  164. #define loseFocusEvent      (osEvt + 17)
  165. #define adjustCursorEvent   (osEvt + 18)
  166.  
  167. #endif /* XP_MAC */
  168.  
  169.  
  170.  
  171.  
  172. #define NP_EMBED        1
  173. #define NP_FULL         2
  174. #define NP_BACKGROUND   3
  175.  
  176. #define NP_NORMAL       1
  177. #define NP_SEEK         2
  178. #define NP_ASFILE       3
  179.  
  180. #define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
  181.  
  182.  
  183. /*
  184.  *  Error and reason code definitions.
  185.  */
  186.  
  187. #define NP_NOERR  0
  188. #define NP_EINVAL 1
  189. #define NP_EABORT 2
  190.  
  191. #define NPERR_BASE                      0
  192. #define NPERR_NO_ERROR                  (NPERR_BASE + 0)
  193. #define NPERR_GENERIC_ERROR             (NPERR_BASE + 1)
  194. #define NPERR_INVALID_INSTANCE_ERROR    (NPERR_BASE + 2)
  195. #define NPERR_INVALID_FUNCTABLE_ERROR   (NPERR_BASE + 3)
  196. #define NPERR_MODULE_LOAD_FAILED_ERROR  (NPERR_BASE + 4)
  197. #define NPERR_OUT_OF_MEMORY_ERROR       (NPERR_BASE + 5)
  198. #define NPERR_INVALID_PLUGIN_ERROR      (NPERR_BASE + 6)
  199. #define NPERR_INVALID_PLUGIN_DIR_ERROR  (NPERR_BASE + 7)
  200. #define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
  201.  
  202. #define NPRES_BASE                      0
  203. #define NPRES_NETWORK_ERR               (NPRES_BASE + 0)
  204. #define NPRES_USER_BREAK                (NPRES_BASE + 1)
  205. #define NPRES_DONE                      (NPRES_BASE + 3)
  206.  
  207.  
  208.  
  209. /*
  210.  *  Function prototypes.
  211.  *  Functions beginning with 'NPP' are functions provided by the plugin that Netscape will call.
  212.  *  Functions beginning with 'NPN' are functions provided by Netscape that the plugin will call.
  213.  */
  214.  
  215. #if defined(_WINDOWS) && !defined(WIN32)
  216. #define NP_LOADDS  _loadds
  217. #else
  218. #define NP_LOADDS
  219. #endif
  220.  
  221. #ifdef __cplusplus
  222. extern "C" {
  223. #endif
  224.  
  225. NPError               NPP_Initialize(void);
  226. void                  NPP_Shutdown(void);
  227. NPError     NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
  228. NPError     NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
  229. NPError     NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
  230. NPError     NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
  231. NPError     NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream, NPError reason);
  232. int32       NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
  233. int32       NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
  234. void        NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
  235. void        NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
  236. int16                 NPP_HandleEvent(NPP instance, void* event);
  237.  
  238. void        NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor);
  239. NPError     NPN_GetURL(NPP instance, const char* url, const char* window);
  240. NPError     NPN_PostURL(NPP instance, const char* url, uint32 len, const char* buf, NPBool file);
  241. NPError     NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
  242. NPError     NPN_NewStream(NPP instance, NPMIMEType type, NPStream* stream);
  243. int32       NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer);
  244. NPError     NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason);
  245. void        NPN_Status(NPP instance, const char* message);
  246. const char* NPN_UserAgent(NPP instance);
  247. void*       NPN_MemAlloc(uint32 size);
  248. void        NPN_MemFree(void* ptr);
  249. uint32      NPN_MemFlush(uint32 size);
  250. void        NPN_ReloadPlugins(NPBool reloadPages);
  251.  
  252. #ifdef __cplusplus
  253. }  /* end extern "C" */
  254. #endif
  255.  
  256. #ifdef __MWERKS__
  257. #pragma options align=reset
  258. #endif
  259.  
  260. #endif /* _NPAPI_H_ */
  261.  
  262.